package com.lkd.service.impl;

import com.lkd.entity.Goods;
import com.lkd.entity.ShoppingCart;
import com.lkd.mapper.ShoppingCartMapper;
import com.lkd.service.IShoppingCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShoppingCartImpl implements IShoppingCartService {
    @Autowired
    private ShoppingCartMapper shoppingCartMapper;

    @Override
    public ShoppingCart checkShoppingCart(ShoppingCart shoppingCart) {
        return shoppingCartMapper.checkShoppingCart(shoppingCart);
    }

    @Override
    public int deleteShoppingCart(ShoppingCart shoppingCart) {
        return shoppingCartMapper.deleteByuserIdgoodsId(Long.valueOf(shoppingCart.getUserId()),Long.valueOf(shoppingCart.getGoodsId()));
    }

    @Override
    public Integer addGoods(int userId, int goodsId) {
        return shoppingCartMapper.addGoods(userId,goodsId);
    }

    @Override
    public int insertGoods(ShoppingCart shoppingCart) {
        return shoppingCartMapper.insertGoods(shoppingCart);
    }

    @Override
    public int downGoods(int userId, int goodsId) {
        return shoppingCartMapper.downGoods(userId, goodsId);
    }

    @Override
    public List<ShoppingCart> queryUserGoods(int userId) {
        return shoppingCartMapper.queryUserGoods(userId);
    }
}
